<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="robots" content="noindex,nofollow"/>
    <title></title>
    <!-- logo -->
    <link rel="shortcut icon" href=" /img/logo.png"/>
    <link rel="stylesheet" href="/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="/js/layui/css/layui.css">
    <script type="text/javascript" src="/js/jquery-3.2.1.min.js"></script>

    <style>
        * {
            margin: 0;
            padding: 0
        }

        .m-login {
            width: 100%;
            height: 100%;
            background: url('/img/login.png') no-repeat;
            background-size: 100% 100%;
            position: absolute;
            font-size: 18px;
        }

        .u-login-content {
            width: 320px;
            text-align: center;
            border-radius: 8px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .u-login-title {
            width: 400px;
            font-size: 26px;
            color: #fff;
            margin-left: -40px;
        }

        .u-login-body .u-login-text {
            display: block;

            width: 80%;
            line-height: 36px;
            margin: 5% auto;
            padding-left: 2%;
            border: 1px solid #DCDCDC;
        }

        .u-login-body .u-login-captcha {
            margin: 0 auto;
            width: 146px;
            display: inline-block;
        }

        .u-login-body .u-login-radio {
            margin-bottom: 5%;
        }

        .u-login-body .u-login-text:focus {
            outline: none;
        }

        .u-login-footer span {
            display: inline-block;
            position: relative;
            width: 80%;
            line-height: 36px;
            font-size: 16px;
            border-radius: 3px;
            background-color: #3DA8F5;
            color: #fff;
            margin-bottom: 15px;
            border: 1px solid #52bea9;
            cursor: pointer;
            box-sizing: border-box;

            transition: padding-right .5s ease;
        }

        .u-login-footer i {
            display: none;
            margin-left: 5px;
            font-size: 24px;
            vertical-align: middle;
            position: absolute;
            top: 7px;
        }

        .u-login-footer span:hover {
            padding-right: 24px;
        }

        .u-login-footer span:hover i {
            display: inline-block;
        }

        .m-login-content {
            padding: 20px 10px;
            margin-top: 20px;
            background: #fff;
            border-radius: 8px;
        }

        .m-login-item {
            font-size: 14px;
            color: #333;
            margin: 10px 0
        }

        .m-login-item input[type="radio"] {
            position: absolute;
            margin-top: 3px;
            margin-left: -6px;
        }

        .m-login-jurisdiction span {
            margin: 10px;
        }

        .u-login-footer {
            margin-top: 10px;
        }
    </style>
</head>
<body>
<section class="m-login">
    <div class="u-login-content">
        <header class="u-login-title">
            框架
        </header>
        <div class="m-login-content">
            <section class="u-login-body">
                <div class="m-login-item">
                    <input class="u-login-text" type="text" name="username" id="username" placeholder="用户名">
                </div>
                <div class="m-login-item">
                    <input class="u-login-text" type="password" name="password" id="password" placeholder="密码">
                </div>
                <div class="m-login-item">
                    <input class="u-login-text u-login-captcha" type="text" name="captcha_code" id="captcha_code"
                           placeholder="验证码">
                    <img src="/manage/login/captcha_code" title="点击更换" id="admin_login_captcha" width="90">
                </div>
            </section>
            <footer class="u-login-footer">
                <span onclick="login();">登陆<i class="fa fa-arrow-circle-right"></i></span>
            </footer>
        </div>
    </div>
</section>
<script type="text/javascript" src="/js/layer/layer.js"></script>
<script type="text/javascript" src="/js/layui/layui.js"></script>
<script>

    $("#admin_login_captcha").click(function () {
        $(this).attr("src", '/index/captcha_code?' + Math.random());
    });

    //用户登陆
    function login() {
        var username = $("#username").val();
        var password = $("#password").val();
        var captcha_code = $("#captcha_code").val();
        if (username == '') {
            layer.tips('用户名不能为空', '#username', {tips: [2, '#3EB6DC']});
            return;
        }

        if (password == '') {
            layer.tips('密码不能为空', '#password', {tips: [2, '#3EB6DC']});
            return;
        }

        if (captcha_code == '') {
            layer.tips('请填写验证码', '#captcha_code', {tips: [1, '#3EB6DC']});
            return;
        }

        $.ajax({
            "method": "POST",
            "url": "/manage/login/check",
            "data": {"username": username, "password": password, "captcha_code": captcha_code, "user_type": "2"},
            "dataType": "json",
            success: function (data) {
                if (data.code == 1000) {
                    window.location.href = "/manage/index";
                } else {
                    layer.msg(data.message);
                }
            }
        });
    }

    $(document).keydown(function (ev) {
        if (ev.keyCode == 13) {
            login();
        }
    })
</script>
</body>

</html>
